package com.nowc.month.m120;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class b {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int T = Integer.parseInt(br.readLine());
        while (T-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
         int n = Integer.parseInt(br.readLine());
         int ans;
         if (n <= 3) {
             ans = -1;
         } else if ((n & 1) == 1) {
             ans = 1;
         } else {
             ans = 2;
         }
         out.println(ans);
    }
}
